﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Mathematics.Expressions
{
    public class FunctionCall:MathExpression
    {

        internal FunctionCall(FunctionDefinition definition,params Parameter[] parameters)
        {
            Definition = definition;
            Parameters = parameters;
        }

        public FunctionDefinition Definition { get; private set; }
        public IEnumerable<Parameter> Parameters { get; private set; }

        public override bool CanEvaluate()
        {
            return Parameters.All(p => p.CanEvaluate());
        }

        public override ExpressionValue Evaluate()
        {
            return Definition.Invoke(this);
        }


        protected internal override MathExpression Reduce(out bool didReduce)
        {
            throw new NotImplementedException();
        }
    }
}
